<?php


namespace app\elastic;

use app\elasticquent\Elastic;

class OrderElastic extends Elastic
{
    protected $collection = 'kdy';

    public $indexName = 'order';

    public $aliasName = 'order_alias';

    protected $fileds = [

    ];

    protected $settings = [
        'number_of_shards' => 1, //分片数 集群节点的1.5倍
        'number_of_replicas' => 1, //副本数
        'analysis' => [
            'analyzer' => [
                'ik_smart_py' => [
                    'type'=>'custom',
                    'tokenizer'=>'ik_smart',
                    'filter' => 'py_filter'
                ],
                'ik_max_word_py' => [
                    'type'=>'custom',
                    'tokenizer'=>'ik_max_word',
                    'filter' => 'py_filter'
                ]
            ],
            'filter' => [
                'py_filter' => [
                    'type' => 'pinyin',
                    'keep_separate_first_letter' => true,
                    'keep_full_pinyin' => true,
                    'keep_original' => true,
                    'limit_first_letter_length' => 16,
                    'lowercase' => true,
                    'remove_duplicated_term' => true
                ]
            ]
        ],
    ];

    protected $mappings = [
        'properties' => [
            'order_id'      => ['type' => 'integer'],
            'order_no'      =>['type' => 'keyword'],
            'out_trade_no'  => ['type' => 'keyword'],
            'order_type'    => ['type' => 'byte'],
            'payment_type'  => ['type' => 'byte'],
            'shipping_type' => ['type' => 'byte'],
            'order_status' => ['type' => 'byte'],
            'pay_status' => ['type' => 'byte'],
            'buyer_id'      => ['type' => 'integer'],
            'user_name'      => ['type' => 'keyword'],
            'buyer_message' => ['type' => 'keyword'],
            'create_time' => ['type' => 'date','format'=>'yyyy-MM-dd HH:mm:ss||epoch_millis'],
            'pay_time' => ['type' => 'date','format'=>'yyyy-MM-dd HH:mm:ss||epoch_millis'],
            'receiver_mobile' => ['type' => 'keyword'],
            'receiver_province' => ['type' => 'keyword'],
            'receiver_city' => ['type' => 'keyword'],
            'receiver_district' => ['type' => 'keyword'],
            'receiver_address' => ['type' => 'keyword'],
            'receiver_name' => ['type' => 'keyword'],
            'goods_money' => ['type' => 'scaled_float','scaling_factor' => 100],
            'order_money' => ['type' => 'scaled_float','scaling_factor' => 100],
            'shipping_money' => ['type' => 'scaled_float','scaling_factor' => 100],
            'pay_money' => ['type' => 'scaled_float','scaling_factor' => 100],
            'data_source' => ['type' => 'byte'],
            'order_item' => [
                'type' => 'nested',
                'properties' => [
                    'order_goods_id' => ['type' => 'integer'],
                    'order_id' => ['type' => 'integer'],
                    'goods_id' => ['type' => 'integer'],
                    'goods_name' => ['type' => 'keyword'],
                    'sku_id' => ['type' => 'integer'],
                    'sku_name' => ['type' => 'keyword'],
                    'price' => ['type' => 'scaled_float','scaling_factor' => 100],
                    'adjust_money' => ['type' => 'scaled_float','scaling_factor' => 100],
                    'goods_money' => ['type' => 'scaled_float','scaling_factor' => 100],
                    'order_real_money' => ['type' => 'scaled_float','scaling_factor' => 100],
                    'goods_picture' => ['type' => 'integer'],
                    'goods_type' => ['type' => 'keyword'],
                    'order_status' => ['type' => 'byte'],
                    'shipping_status' => ['type' => 'byte'],
                    'refund_status' => ['type' => 'byte'],
                    'refund_time' => ['type' => 'date','format'=>'yyyy-MM-dd HH:mm:ss||epoch_millis'],
                ],
            ],
        ]
    ];
}
